<template>
    <view>
        <view class="paddbottom">
            <view class="blbanner">
                <view class="b-head" :style="'border-color:' + color">排队列表</view>
            </view>
            <block v-for="(item, index) in NumberList" :key="index">
                <view class="ddlb">
                    <view style="border-right: 1px solid #f0f0f0">
                        <text class="text">当前叫号</text>
                        <text class="num" :style="'color:' + color">{{ item.dq }}</text>
                    </view>
                    <view style="border-right: 1px solid #f0f0f0">
                        <text class="text">桌号分类</text>
                        <text class="num">{{ item.num }}</text>
                    </view>
                    <view style="justify-content: center">
                        <view class="qhsx" :style="'background:' + color">
                            <view>取号</view>
                            <view>（{{ item.rs }}/{{ item.count }}）</view>
                        </view>
                    </view>
                </view>

                <view class="tjlb">
                    <view @tap="ckyl" :data-id="item.num">
                        <image class="image" mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/sjd/qhfl.png"></image>
                        <view>查看已领</view>
                    </view>
                    <view @tap="call" :data-id="item.id" :style="'border-color:' + color + ';color:' + color">
                        <image class="image" mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/sjd/jh.png"></image>
                        <view>叫号</view>
                    </view>
                    <view @tap="sitdown" :data-id="item.pid" :style="'border-color:' + color + ';color:' + color">
                        <image class="image" mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/sjd/rz.png"></image>
                        <view>入座</view>
                    </view>
                    <view @tap="pass" :data-id="item.pid" :style="'border-color:' + color + ';color:' + color">
                        <image class="image" mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/sjd/qhtg.png"></image>
                        <view>跳过</view>
                    </view>
                </view>
            </block>
        </view>
        <form @reset="formReset" @submit="formSubmit" :reportSubmit="true">
            <view class="dbbtn">
                <button formType="submit" :style="'background:' + color + ';color: #fff;'">添加分类</button>
            </view>
        </form>
        <button @tap="refresh" class="hddb">
            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/shuaxin.png"></image>
        </button>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var app = getApp();
var siteinfo = require('../../../../siteinfo.js');
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            jrdd: '0',
            jrcj: '0',
            NumberList: '',
            color: ''
        };
    },
    onLoad: function (t) {
        uni.setNavigationBarTitle({
            title: '排队取号'
        });
        this.reLoad();
        var o = uni.getStorageSync('sjdsjid');
        console.log(o, uni.getStorageSync('system'));
        app.globalData.setNavigationBarColor(this);
        app.globalData.sjdappPageOnLoad(this);
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    methods: {
        formSubmit: function (t) {
            var o = uni.getStorageSync('users').id;
            console.log(o);
            uni.showLoading({
                title: '跳转中'
            });
            app.globalData.util.request({
                url: 'entry/wxapp/AddFormId',
                cachetime: '0',
                data: {
                    user_id: o,
                    form_id: t.detail.formId
                },
                success: function (t) {
                    console.log(t.data, o);
                    uni.navigateTo({
                        url: 'pdfl'
                    });
                }
            });
        },

        reLoad: function () {
            var that = this;
            app.globalData.util.request({
                url: 'entry/wxapp/NumberList',
                cachetime: '0',
                data: {
                    store_id: uni.getStorageSync('sjdsjid')
                },
                success: function (t) {
                    console.log(t.data);
                    that.setData({
                        NumberList: t.data
                    });
                }
            });
        },

        refresh: function () {
            uni.showToast({
                title: '刷新数据',
                icon: 'loading'
            });
            this.reLoad();
        },

        ckyl: function (t) {
            var o = t.currentTarget.dataset.id;
            console.log(o);
            uni.navigateTo({
                url: 'pdxq?typename=' + t.currentTarget.dataset.id
            });
        },

        call: function (t) {
            var o = t.currentTarget.dataset.id;
            var e = siteinfo.siteroot.replace('app/index.php', '');
            console.log(o, e);
            uni.showModal({
                title: '提示',
                content: '确认叫号吗？',
                success: function (t) {
                    if (t.confirm) {
                        console.log('用户点击确定');
                        app.globalData.util.request({
                            url: 'entry/wxapp/QueryNumber',
                            cachetime: '0',
                            data: {
                                id: o
                            },
                            success: function (t) {
                                console.log(t, t.data);
                                uni.playBackgroundAudio({
                                    dataUrl: e + t.data,
                                    title: '语音播报'
                                });
                            }
                        });
                    } else {
                        if (t.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                }
            });
        },

        sitdown: function (t) {
            var that = this;
            var e = t.currentTarget.dataset.id;
            console.log(e);
            uni.showModal({
                title: '提示',
                content: '确认入座此号吗？',
                success: function (t) {
                    if (t.confirm) {
                        console.log('用户点击确定');
                        app.globalData.util.request({
                            url: 'entry/wxapp/Pdrz',
                            cachetime: '0',
                            data: {
                                id: e
                            },
                            success: function (t) {
                                console.log(t);
                                if (1 == t.data) {
                                    uni.showToast({
                                        title: '操作成功',
                                        duration: 1000
                                    });
                                    setTimeout(function () {
                                        that.reLoad();
                                    }, 1000);
                                }
                            }
                        });
                    } else {
                        if (t.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                }
            });
        },

        pass: function (t) {
            var that = this;
            var e = t.currentTarget.dataset.id;
            console.log(e);
            uni.showModal({
                title: '提示',
                content: '确认跳过此号吗？',
                success: function (t) {
                    if (t.confirm) {
                        console.log('用户点击确定');
                        app.globalData.util.request({
                            url: 'entry/wxapp/Pdth',
                            cachetime: '0',
                            data: {
                                id: e
                            },
                            success: function (t) {
                                console.log(t);
                                if (1 == t.data) {
                                    uni.showToast({
                                        title: '操作成功',
                                        duration: 1000
                                    });
                                    setTimeout(function () {
                                        that.reLoad();
                                    }, 1000);
                                }
                            }
                        });
                    } else {
                        if (t.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                }
            });
        },

        formReset() {
            console.log('占位：函数 formReset 未声明');
        }
    }
};
</script>
<style>
@import './pdlb.css';
</style>
